import java.sql.*;
public class Population {
    public static void main(String args[]) {
        Connection con=null;
        Statement sql;
        ResultSet rs;
        String uri = "jdbc:mysql://localhost:3306/world";
        String user ="root";
        String password ="";
        try{
            con = DriverManager.getConnection(uri,user,password);
        }
        catch(SQLException e){
            System.out.println(e);
        }
        try {
            long sum=0;
            if (con == null) return;
            String c=" like 'Middle East'";
            sql=con.createStatement();
            String sqlStr = "select * from country where Region"+c;
            rs=sql.executeQuery(sqlStr);
            while(rs.next()) {
                int Population=rs.getInt(7);
                sum=sum+Population;
            }
            System.out.printf("%d\n",sum);
            con.close();
        }
        catch(SQLException e) {
            System.out.println(e);
        }
    }
}